package com.twl.app.base.ctrl;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.twl.app.base.bo.SalaryBoImpoty;
import com.twl.app.base.entity.CheckDate;
import com.twl.app.base.entity.Checktemplet;
import com.twl.app.base.entity.Companyb;
import com.twl.app.base.entity.Miniwase;
import com.twl.app.base.entity.SalParam;
import com.twl.app.base.entity.SalSalaryData;
import com.twl.app.base.entity.SalSocialAdjust;
import com.twl.app.base.entity.Uemp;
import com.twl.common.constant.SalConstant;
import com.twl.core.framework.ctrl.AbsCrudCtrl;
import com.twl.core.framework.page.ExpResult;
import com.twl.core.framework.page.Page;
import com.twl.core.framework.page.Result;

@Service("salaryImportImp")
public class SalaryImportImp extends AbsCrudCtrl<SalaryBoImpoty> {

	@Autowired
	private CommonCtrlImpl commonCtrlImpl;
	

	/**
	 * 更新出勤日期
	 * 
	 * @param date
	 * @return
	 */
	public String updateDate(Map<String, Object> map) {
		StringBuffer sb = new StringBuffer("update Checkdate set ");
		String iswork = map.get("iswork") == null ? null : String.valueOf(map.get("iswork"));
		if (map.get("iswork") != null) {
			sb.append(" iswork= '").append(iswork).append("' ");
		}
		String did = map.get("did") == null ? null : String.valueOf(map.get("did"));
		sb.append(" where did= '" + did + "' ");
		// 去掉第一个,
		String str = sb.toString().replaceFirst(",", "");

		return bo.updateDate(str);
		// return bo.updateDate(sb.toString());
	}

	/**
	 * 批量更新出勤日期
	 * 
	 * @param ids
	 * @return
	 */
	public Integer updateWorkdays(Integer[] ids) {
		return bo.updateWorkdays(ids);
	}

	public Integer updateWeekdays(Integer[] ids) {
		return bo.updateWeekdays(ids);
	}

	/**
	 * 增加出勤表
	 * 
	 * @return
	 */
	public String insertDate(CheckDate checkDate) {

		return bo.insertDate(checkDate);

	}

	/***
	 * 查询出勤日期
	 */
	public Result queryDate(Map<String, Object> params) {
		Page page = (Page) params.get("page");
		StringBuffer sbf = new StringBuffer("from CheckDate where 1=1");
		String yearmonth = params.get("yearmonth") == null ? null : String.valueOf(params.get("yearmonth")).replaceAll("年", "").replaceAll("月", "");

		if (StringUtils.isNotBlank(yearmonth)) {
			sbf.append(" and yearmonth='" + yearmonth + "'");
		}
		return bo.queryDate(sbf.toString(), page);

	}

	/***
	 * 增加考勤表5879555
	 * 
	 * 95555 *
	 * 
	 * @param object
	 * @return
	 */
	public String savechecktemplet(Checktemplet let) {

		return bo.savechecktemplet(let);
	}

	/***
	 * 查询考勤表
	 * 
	 * @param params
	 * @return
	 */
	public Result selectchecktemplet(Map<String, Object> params) {
		Page page = (Page) params.get("page");
		StringBuffer sql = new StringBuffer("from Checktemplet where 1=1");

		String did = params.get("did") == null ? null : String.valueOf(params.get("did"));
		if (StringUtils.isNotBlank(did)) {
			sql.append(" and did='" + did + "'");
		}

		String period = params.get("period") == null ? null : String.valueOf(params.get("period")).replace("年", "").replace("月", "");
		if (StringUtils.isNotBlank(period)) {
			sql.append(" and period like'%'||'" + period + "'||'%'");
		}
		String staffint = params.get("staffint") == null ? null : String.valueOf(params.get("staffint"));
		if (StringUtils.isNotBlank(staffint)) {
			sql.append(" and staffint like'%'||'" + staffint + "'||'%'");
		}
		String staffname = params.get("staffname") == null ? null : String.valueOf(params.get("staffname"));
		if (StringUtils.isNotBlank(staffname)) {
			sql.append(" and staffname like'%'||'" + staffname + "'||'%'");
		}

		return bo.selectchecktemplet(sql.toString(), page);
	}

	/***
	 * 导出考勤表
	 * 
	 * @param params
	 * @return
	 */
	public ExpResult expChecktemplet(Map<String, Object> params) {
		Page page = (Page) params.get("page");
		StringBuffer sql = new StringBuffer("from Checktemplet where 1=1");

		String did = params.get("did") == null ? null : String.valueOf(params.get("did"));
		if (StringUtils.isNotBlank(did)) {
			sql.append(" and did='" + did + "'");
		}
		String period = params.get("period") == null ? null : String.valueOf(params.get("period")).replace("年", "").replace("月", "");
		if (StringUtils.isNotBlank(period)) {
			sql.append(" and period like'%'||'" + period + "'||'%'");
		}
		String staffint = params.get("staffint") == null ? null : String.valueOf(params.get("staffint"));
		if (StringUtils.isNotBlank(staffint)) {
			sql.append(" and staffint like'%'||'" + staffint + "'||'%'");
		}
		String staffname = params.get("staffname") == null ? null : String.valueOf(params.get("staffname"));
		if (StringUtils.isNotBlank(staffname)) {
			sql.append(" and staffname like'%'||'" + staffname + "'||'%'");
		}
		return bo.getExpResult(sql.toString(), page);
	}

	/***
	 * 导出参保比例
	 * 
	 * @param params
	 * @return
	 */
	public ExpResult expCompanyb(Map<String, Object> params) {
		Page page = (Page) params.get("page");
		StringBuffer sql = new StringBuffer("from Companyb where 1=1");

		String did = params.get("did") == null ? null : String.valueOf(params.get("did"));
		if (StringUtils.isNotBlank(did)) {
			sql.append(" and did='" + did + "'");
		}
		String staffint = params.get("staffint") == null ? null : String.valueOf(params.get("staffint"));
		if (StringUtils.isNotBlank(staffint)) {
			sql.append(" and staffint like '%" + staffint + "%'");
		}
		return bo.getExpResult(sql.toString(), page);
	}

	/***
	 * 导出薪资数据
	 * 
	 * @param params
	 * @return
	 */
	public ExpResult expSalSalaryData(Map<String, Object> params) {
		Page page = (Page) params.get("page");

		StringBuffer sql = new StringBuffer("from SalSalaryData where 1=1 and isDelete='" + SalConstant.NOT_DELETE + "' ");

		String did = params.get("did") == null ? null : String.valueOf(params.get("did"));
		if (StringUtils.isNotBlank(did)) {
			sql.append(" and did='" + did + "'");
		}
		String staffint = params.get("staffint") == null ? null : String.valueOf(params.get("staffint"));
		if (StringUtils.isNotBlank(staffint)) {
			sql.append(" and staffint like'%'||'" + staffint + "'||'%'");
		}

		String name = params.get("name") == null ? null : String.valueOf(params.get("name"));
		if (StringUtils.isNotBlank(name)) {
			sql.append(" and name like'%'||'" + name + "'||'%'");
		}

		String idNumber = params.get("idNumber") == null ? null : String.valueOf(params.get("idNumber"));
		if (StringUtils.isNotBlank(idNumber)) {
			sql.append(" and idNumber like'%'||'" + idNumber + "'||'%'");
		}
		
		String period = params.get("period") == null ? null : String.valueOf(params.get("period")).replace("年", "").replace("月", "");
		if (StringUtils.isNotBlank(period)) {
			sql.append(" and period like'%'||'" + period + "'||'%'");
		}
		return bo.getExpResult(sql.toString(), page);
	}

	/***
	 * 导出员工
	 * 
	 * @param params
	 * @return
	 */
	public ExpResult expUemp(Map<String, Object> params) {
		Page page = (Page) params.get("page");
		StringBuffer sql = new StringBuffer("from Uemp where 1=1 and delstaff=0");

		String did = params.get("did") == null ? null : String.valueOf(params.get("did"));
		if (StringUtils.isNotBlank(did)) {
			sql.append(" and did='" + did + "'");
		}
		String staffint = params.get("staffint") == null ? null : String.valueOf(params.get("staffint"));
		if (StringUtils.isNotBlank(staffint)) {
			sql.append(" and staffint like '%" + staffint + "%'");
		}

		String stafftype = params.get("stafftype") == null ? null : String.valueOf(params.get("stafftype"));
		stafftype= stafftype== "==不限==" ? null : stafftype;
		if (StringUtils.isNotBlank(stafftype)) {
			sql.append(" and stafftype like'%'||'" + stafftype + "'||'%'");
		}

		String stafftypes = params.get("stafftypes") == null ? null : String.valueOf(params.get("stafftypes"));
		stafftypes= stafftypes== "==不限==" ? null : stafftypes;
		if (StringUtils.isNotBlank(stafftypes)) {
			sql.append(" and stafftypes like'%'||'" + stafftypes + "'||'%'");
		}
		
		String staffname = params.get("staffname") == null ? null : String.valueOf(params.get("staffname"));
		if (StringUtils.isNotBlank(staffname)) {
			sql.append(" and staffname like'%'||'" + staffname + "'||'%'");
		}

		String dept = params.get("dept") == null ? null : String.valueOf(params.get("dept"));
		if (StringUtils.isNotBlank(dept)) {
			sql.append(" and dept like'%'||'" + dept + "'||'%'");
		}

		String tean = params.get("tean") == null ? null : String.valueOf(params.get("tean"));
		if (StringUtils.isNotBlank(tean)) {
		sql.append(" and tean like'%'||'" + tean + "'||'%'");
		}
		
		String cardlevel = params.get("cardlevel") == null ? null : String.valueOf(params.get("cardlevel"));
		cardlevel= cardlevel== "==不限==" ? null : cardlevel;
		if (StringUtils.isNotBlank(cardlevel)) {
			sql.append(" and cardlevel like'%'||'" + cardlevel + "'||'%'");
		}

		String assailedcom = params.get("assailedcom") == null ? null : String.valueOf(params.get("assailedcom"));
		assailedcom= assailedcom== "==不限==" ? null : assailedcom;
		if (StringUtils.isNotBlank(assailedcom)) {
			sql.append(" and assailedcom like'%'||'" + assailedcom + "'||'%'");
		}

		String jobsort = params.get("jobsort") == null ? null : String.valueOf(params.get("jobsort"));
		if (StringUtils.isNotBlank(jobsort)) {
				sql.append(" and jobsort like'%'||'" + jobsort + "'||'%'");
		}
		return bo.getExpResult(sql.toString(), page);
	}

	/**
	 * 增加员工表
	 * 
	 * @param emp
	 * @return
	 * @throws ParseException
	 * @throws Exception
	 */
	public String saveump(Uemp emp)  {
		Uemp mp = commonCtrlImpl.getUemp(emp.getStaffint());
	
		if (mp != null) {
			// 先修改
			StringBuffer buff = new StringBuffer("update Uemp set delstaff=1 where staffint='" + mp.getStaffint() + "'");
			int num = bo.updateuemp(buff.toString());
			String str = bo.saveuemp(emp);
			return str;
		}
		
		return bo.saveuemp(emp);
	}

	/***
	 * 增加社保
	 * 
	 * @param com
	 * @return
	 */
	public String savecompanyb(Companyb com) {
		return bo.savecompanyb(com);
	}

	/**
	 * 查询社保表
	 * 
	 * @param params
	 * @return
	 */
	public Result selectcomp(Map<String, Object> params) {
		Page page = (Page) params.get("page");
		StringBuffer sql = new StringBuffer("from Companyb where 1=1");
		String nature = params.get("nature") == null ? null : String.valueOf(params.get("nature"));
		if (StringUtils.isNotBlank(nature)) {
			sql.append(" and nature='" + nature + "'");
		}
		String did = params.get("did") == null ? null : String.valueOf(params.get("did"));
		if (StringUtils.isNotBlank(did)) {
			sql.append(" and did='" + did + "'");
		}

		return bo.selectcomp(sql.toString(), page);
	}

	/***
	 * 修改社保
	 * 
	 * @param map
	 * @return
	 */
	public int updatecomp(Map<String, Object> map) {

		StringBuffer buff = new StringBuffer("update Companyb set ");
		if (map.get("nature") != null) {
			buff.append(", nature='").append(map.get("nature")).append("' ");
		}
		if (map.get("accumuldan") != null) {
			buff.append(", accumuldan='").append(map.get("accumuldan")).append("' ");
		}
		if (map.get("nursingdan") != null) {
			buff.append(", nursingdan='").append(map.get("nursingdan")).append("' ");
		}
		if (map.get("healthdan") != null) {
			buff.append(", healthdan='").append(map.get("healthdan")).append("' ");
		}
		if (map.get("unempdan") != null) {
			buff.append(", unempdan='").append(map.get("unempdan")).append("' ");
		}
		if (map.get("firmsdan") != null) {
			buff.append(", firmsdan='").append(map.get("firmsdan")).append("' ");
		}
		if (map.get("fertilitydan") != null) {
			buff.append(", fertilitydan='").append(map.get("fertilitydan")).append("' ");
		}
		if (map.get("Handidan") != null) {
			buff.append(", Handidan='").append(map.get("Handidan")).append("' ");
		}
		if (map.get("diseasedan") != null) {
			buff.append(", diseasedan='").append(map.get("diseasedan")).append("' ");
		}
		if (map.get("accumulper") != null) {
			buff.append(", accumulper='").append(map.get("accumulper")).append("' ");
		}
		if (map.get("nursingper") != null) {
			buff.append(", nursingper='").append(map.get("nursingper")).append("' ");
		}
		if (map.get("healthper") != null) {
			buff.append(", healthper='").append(map.get("healthper")).append("' ");
		}
		if (map.get("unempper") != null) {
			buff.append(", unempper='").append(map.get("unempper")).append("' ");
		}

		buff.append(" where did='" + map.get("did") + "'");
		// 去掉第一个,
		String str = buff.toString().replaceFirst(",", "");

		return bo.updatecomp(str);
	}

	/***
	 * 删除 社保
	 * 
	 * @param id
	 * @return
	 */
	public int delcomp(String id) {
		return bo.delcomp(id);
	}

	/**
	 * 批量删除社保
	 * 
	 * @param ids
	 * @return
	 */
	public Integer batchDelCompanyb(Integer[] ids) {
		return bo.batchDelCompanyb(ids);
	}

	/***
	 * 查询员工信息
	 */
	public List<Uemp> selectuemp(String id) {
		String sql = "from Uemp where 1=1  and delstaff=0 and staffint='" + id + "'";
		return bo.selectuemp(sql);
	}

	/***
	 * 查询员工信息
	 */
	public List<Uemp> selectUempByDid(String id) {
		String sql = "from Uemp where 1=1  and delstaff=0 and did='" + id + "'";
		return bo.selectuemp(sql);
	}

	/***
	 * cms调用员工信息
	 * 
	 * @param param
	 * @return
	 */
	public Result selectuempstr(Map<String, Object> param) {
		Page page = (Page) param.get("page");
		StringBuffer buff = new StringBuffer("from Uemp where 1=1 and delstaff=0 ");

		String did = param.get("did") == null ? null : String.valueOf(param.get("did"));
		if (StringUtils.isNotBlank(did)) {
			buff.append(" and did='").append(did + "'");
		}

		String staffint = param.get("staffint") == null ? null : String.valueOf(param.get("staffint"));
		if (StringUtils.isNotBlank(staffint)) {
			buff.append(" and staffint like'%'||'" + staffint + "'||'%'");
		}

		String stafftype = param.get("stafftype") == null ? null : String.valueOf(param.get("stafftype"));
		stafftype= stafftype== "==不限==" ? null : stafftype;
		if (StringUtils.isNotBlank(stafftype)) {
			buff.append(" and stafftype like'%'||'" + stafftype + "'||'%'");
		}

		String stafftypes = param.get("stafftypes") == null ? null : String.valueOf(param.get("stafftypes"));
		stafftypes= stafftypes== "==不限==" ? null : stafftypes;
		if (StringUtils.isNotBlank(stafftypes)) {
			buff.append(" and stafftypes like'%'||'" + stafftypes + "'||'%'");
		}
		
		String staffname = param.get("staffname") == null ? null : String.valueOf(param.get("staffname"));
		if (StringUtils.isNotBlank(staffname)) {
			buff.append(" and staffname like'%'||'" + staffname + "'||'%'");
		}

		String dept = param.get("dept") == null ? null : String.valueOf(param.get("dept"));
		if (StringUtils.isNotBlank(dept)) {
			buff.append(" and dept like'%'||'" + dept + "'||'%'");
		}

		String tean = param.get("tean") == null ? null : String.valueOf(param.get("tean"));
		if (StringUtils.isNotBlank(tean)) {
		buff.append(" and tean like'%'||'" + tean + "'||'%'");
		}
		
		String cardlevel = param.get("cardlevel") == null ? null : String.valueOf(param.get("cardlevel"));
		cardlevel= cardlevel== "==不限==" ? null : cardlevel;
		if (StringUtils.isNotBlank(cardlevel)) {
			buff.append(" and cardlevel like'%'||'" + cardlevel + "'||'%'");
		}

		String assailedcom = param.get("assailedcom") == null ? null : String.valueOf(param.get("assailedcom"));
		assailedcom= assailedcom== "==不限==" ? null : assailedcom;
		assailedcom= assailedcom== "无派遣公司" ? null : assailedcom;
		if (StringUtils.isNotBlank(assailedcom)) {
			buff.append(" and assailedcom like'%'||'" + assailedcom + "'||'%'");
		}

		String jobsort = param.get("jobsort") == null ? null : String.valueOf(param.get("jobsort"));
		if (StringUtils.isNotBlank(jobsort)) {
				buff.append(" and jobsort like'%'||'" + jobsort + "'||'%'");
		}
	
		return bo.selectuempstr(buff.toString(), page);
	}

	/***
	 * 删除员工
	 * 
	 * @param sql
	 * @return
	 */
	public int deluemp(String id) {
		String sql = "update  Uemp  set delstaff=1 where  did='" + id + "'";
		int num = bo.deluemp(sql);
		return num;
	}

	/**
	 * 批量删除社保
	 * 
	 * @param ids
	 * @return
	 */
	public Integer batchDelUemp(Integer[] ids) {
		return bo.batchDelUemp(ids);
	}

	/**
	 * 根据ID删除考勤
	 * 
	 * @param id
	 * @return
	 */
	public int delChecktemplet(String id) {
		String sql = "delete Checktemplet t where t.did =" + id;
		return bo.executeSql(sql);
	}

	/**
	 * 批量删除考勤
	 * 
	 * @param ids
	 * @return
	 */
	public Integer batchDelChecktemplet(Integer[] ids) {
		return bo.batchDelChecktemplet(ids);
	}

	/**
	 * 保存薪资数据
	 * 
	 * @param data
	 * @return
	 */
	public Integer saveSalSalaryData(SalSalaryData data) {
		return bo.saveSalSalaryData(data);
	}

	/**
	 * 删除薪资数据
	 * 
	 * @param ids
	 * @return
	 */
	public Integer delSalSalaryData(Integer[] ids) {
		return bo.delSalSalaryData(ids);
	}

	/**
	 * 查询薪资数据
	 * 
	 * @param params
	 * @return
	 */
	public Result querySalaryData(Map<String, Object> params) {
		Page page = (Page) params.get("page");
		StringBuffer buff = new StringBuffer("from SalSalaryData where 1=1 and isDelete='" + SalConstant.NOT_DELETE + "' ");

		String did = params.get("did") == null ? null : String.valueOf(params.get("did"));
		if (StringUtils.isNotBlank(did)) {
			buff.append(" and did='").append(did + "'");
		}
		String period = params.get("period") == null ? null : String.valueOf(params.get("period")).replace("年", "").replace("月", "");
		if (StringUtils.isNotBlank(period)) {
			buff.append(" and period like'%'||'" + period + "'||'%'");
		}
		String staffint = params.get("staffint") == null ? null : String.valueOf(params.get("staffint"));
		if (StringUtils.isNotBlank(staffint)) {
			buff.append(" and staffint like'%'||'" + staffint + "'||'%'");
		}

		String name = params.get("name") == null ? null : String.valueOf(params.get("name"));
		if (StringUtils.isNotBlank(name)) {
			buff.append(" and name like'%'||'" + name + "'||'%'");
		}

		String idNumber = params.get("idNumber") == null ? null : String.valueOf(params.get("idNumber"));
		if (StringUtils.isNotBlank(idNumber)) {
			buff.append(" and idNumber like'%'||'" + idNumber + "'||'%'");
		}

		return bo.querySalaryData(buff.toString(), page);
	}

	/***
	 * 导出社保调整
	 * 
	 * @param params
	 * @return
	 */
	public ExpResult expSalSocialAdjust(Map<String, Object> params) {
		Page page = (Page) params.get("page");

		StringBuffer sql = new StringBuffer("from SalSocialAdjust where 1=1 and isDelete='" + SalConstant.NOT_DELETE + "' ");

		String id = params.get("id") == null ? null : String.valueOf(params.get("id"));
		if (StringUtils.isNotBlank(id)) {
			sql.append(" and id='" + id + "'");
		}
		String staffint = params.get("staffint") == null ? null : String.valueOf(params.get("staffint"));
		if (StringUtils.isNotBlank(staffint)) {
			sql.append(" and staffint like'%'||'" + staffint + "'||'%'");
		}
		String period = params.get("period") == null ? null : String.valueOf(params.get("period")).replace("年", "").replace("月", "");
		if (StringUtils.isNotBlank(period)) {
			sql.append(" and period like'%'||'" + period + "'||'%'");
		}
		
		String name = params.get("name") == null ? null : String.valueOf(params
				.get("name"));
		if (StringUtils.isNotBlank(name)) {
			sql.append(" and name like'%'||'" + name + "'||'%'");
		}
		String idNumber = params.get("idNumber") == null ? null : String
				.valueOf(params.get("idNumber"));
		if (StringUtils.isNotBlank(idNumber)) {
			sql.append(" and idNumber like'%'||'" + idNumber + "'||'%'");
		}
		// String name = params.get("name") == null ? null :
		// String.valueOf(params.get("name"));
		// if (StringUtils.isNotBlank(name)) {
		// sql.append(" and name like'%'||'" + name + "'||'%'");
		// }

		// String idNumber = params.get("idNumber") == null ? null :
		// String.valueOf(params.get("idNumber"));
		// if (StringUtils.isNotBlank(idNumber)) {
		// sql.append(" and idNumber like'%'||'" + idNumber + "'||'%'");
		// }
		return bo.getExpResult(sql.toString(), page);
	}

	/**
	 * 保存社保调整
	 * 
	 * @param data
	 * @return
	 */
	public Integer saveSalSocialAdjust(SalSocialAdjust data) {
		return bo.saveSalSocialAdjust(data);
	}

	/**
	 * 删除社保调整
	 * 
	 * @param ids
	 * @return
	 */
	public Integer delSalSocialAdjust(Integer[] ids) {
		return bo.delSalSocialAdjust(ids);
	}

	/**
	 * 查询社保调整
	 * 
	 * @param params
	 * @return
	 */
	public Result querySalSocialAdjust(Map<String, Object> params) {
		Page page = (Page) params.get("page");
		StringBuffer buff = new StringBuffer("from SalSocialAdjust where 1=1 and isDelete='" + SalConstant.NOT_DELETE + "' ");

		String id = params.get("id") == null ? null : String.valueOf(params.get("id"));
		if (StringUtils.isNotBlank(id)) {
			buff.append(" and id='").append(id + "'");
		}
		String period = params.get("period") == null ? null : String.valueOf(params.get("period")).replace("年", "").replace("月", "");
		if (StringUtils.isNotBlank(period)) {
			buff.append(" and period like'%'||'" + period + "'||'%'");
		}
		String staffint = params.get("staffint") == null ? null : String.valueOf(params.get("staffint"));
		if (StringUtils.isNotBlank(staffint)) {
			buff.append(" and staffint like'%'||'" + staffint + "'||'%'");
		}

		String name = params.get("name") == null ? null : String.valueOf(params
				.get("name"));
		if (StringUtils.isNotBlank(name)) {
			buff.append(" and name like'%'||'" + name + "'||'%'");
		}

		String idNumber = params.get("idNumber") == null ? null : String
				.valueOf(params.get("idNumber"));
		if (StringUtils.isNotBlank(idNumber)) {
			buff.append(" and idNumber like'%'||'" + idNumber + "'||'%'");
		}

		/*
		 * String staffint = params.get("staffint") == null ? null :
		 * String.valueOf(params.get("staffint")); if
		 * (StringUtils.isNotBlank(staffint)) {
		 * buff.append(" and staffint like'%'||'" + staffint + "'||'%'"); }
		 */

		// String name = params.get("name") == null ? null :
		// String.valueOf(params.get("name"));
		// if (StringUtils.isNotBlank(name)) {
		// buff.append(" and name like'%'||'" + name + "'||'%'");
		// }

		// String idNumber = params.get("idNumber") == null ? null :
		// String.valueOf(params.get("idNumber"));
		// if (StringUtils.isNotBlank(idNumber)) {
		// buff.append(" and idNumber like'%'||'" + idNumber + "'||'%'");
		// }

		return bo.querySalSocialAdjust(buff.toString(), page);
	}

	/***
	 * 导出薪资系统参数
	 * 
	 * @param params
	 * @return
	 */
	public ExpResult expSalParam(Map<String, Object> params) {
		Page page = (Page) params.get("page");

		StringBuffer sql = new StringBuffer("from SalParam where 1=1 and isDelete='" + SalConstant.NOT_DELETE + "' ");

		String paramId = params.get("paramId") == null ? null : String.valueOf(params.get("paramId"));
		if (StringUtils.isNotBlank(paramId)) {
			sql.append(" and paramId='" + paramId + "'");
		}

		String paramType = params.get("paramType") == null ? null : String.valueOf(params.get("paramType"));
		if (StringUtils.isNotBlank(paramType)) {
			sql.append(" and paramType like'%'||'" + paramType + "'||'%'");
		}

		String paramTypeName = params.get("paramTypeName") == null ? null: String.valueOf(params.get("paramTypeName"));
		if (StringUtils.isNotBlank(paramTypeName)) {
			sql.append(" and paramTypeName like'%'||'" + paramTypeName
					+ "'||'%'");
		}
		String paramKey = params.get("paramKey") == null ? null : String.valueOf(params.get("paramKey"));
		if (StringUtils.isNotBlank(paramKey)) {
			sql.append(" and paramKey like'%'||'" + paramKey + "'||'%'");
		}

		String paramKeyName = params.get("paramKeyName") == null ? null
				: String.valueOf(params.get("paramKeyName"));
		if (StringUtils.isNotBlank(paramKeyName)) {
			sql.append(" and paramKeyName like'%'||'" + paramKeyName
					+ "'||'%'");
		}
		// String name = params.get("name") == null ? null :
		// String.valueOf(params.get("name"));
		// if (StringUtils.isNotBlank(name)) {
		// sql.append(" and name like'%'||'" + name + "'||'%'");
		// }

		// String idNumber = params.get("idNumber") == null ? null :
		// String.valueOf(params.get("idNumber"));
		// if (StringUtils.isNotBlank(idNumber)) {
		// sql.append(" and idNumber like'%'||'" + idNumber + "'||'%'");
		// }
		return bo.getExpResult(sql.toString(), page);
	}

	/**
	 * 保存薪资系统参数
	 * 
	 * @param data
	 * @return
	 */
	public Integer saveSalParam(SalParam data) {
		return bo.saveSalParam(data);
	}

	/**
	 * 删除薪资系统参数
	 * 
	 * @param ids
	 * @return
	 */
	public Integer delSalParam(Integer[] ids) {
		return bo.delSalParam(ids);
	}

	/**
	 * 查询薪资系统参数
	 * 
	 * @param params
	 * @return
	 */
	public Result querySalParam(Map<String, Object> params) {
		Page page = (Page) params.get("page");
		StringBuffer buff = new StringBuffer("from SalParam where 1=1 and isDelete='" + SalConstant.NOT_DELETE + "' ");

		String paramId = params.get("paramId") == null ? null : String.valueOf(params.get("paramId"));
		if (StringUtils.isNotBlank(paramId)) {
			buff.append(" and paramId='").append(paramId + "'");
		}

		String paramType = params.get("paramType") == null ? null : String.valueOf(params.get("paramType"));
		if (StringUtils.isNotBlank(paramType)) {
			buff.append(" and paramType like'%'||'" + paramType + "'||'%'");
		}

		String paramTypeName = params.get("paramTypeName") == null ? null: String.valueOf(params.get("paramTypeName"));
		if (StringUtils.isNotBlank(paramTypeName)) {
			buff.append(" and paramTypeName like'%'||'" + paramTypeName
					+ "'||'%'");
		}
		String paramKey = params.get("paramKey") == null ? null : String.valueOf(params.get("paramKey"));
		if (StringUtils.isNotBlank(paramKey)) {
			buff.append(" and paramKey like'%'||'" + paramKey + "'||'%'");
		}

		String paramKeyName = params.get("paramKeyName") == null ? null
				: String.valueOf(params.get("paramKeyName"));
		if (StringUtils.isNotBlank(paramKeyName)) {
			buff.append(" and paramKeyName like'%'||'" + paramKeyName
					+ "'||'%'");
		}
		return bo.querySalParam(buff.toString(), page);
	}

	/***
	 * 导出最低工资参数
	 * 
	 * @param params
	 * @return
	 */
	public ExpResult expMiniwase(Map<String, Object> params) {
		Page page = (Page) params.get("page");

		StringBuffer sql = new StringBuffer("from Miniwase where 1=1 and isDelete='" + SalConstant.NOT_DELETE + "' ");

		String did = params.get("did") == null ? null : String.valueOf(params.get("did"));
		if (StringUtils.isNotBlank(did)) {
			sql.append(" and did='" + did + "'");
		}
		String engli = params.get("engli") == null ? null : String.valueOf(params.get("engli"));
		if (StringUtils.isNotBlank(engli)) {
			sql.append(" and engli like'%'||'" + engli + "'||'%'");
		}

		String engtype = params.get("engtype") == null ? null : String.valueOf(params.get("engtype"));
		if (StringUtils.isNotBlank(engtype)) {
			sql.append(" and engtype like'%'||'" + engtype + "'||'%'");
		}

		String idtion = params.get("idtion") == null ? null : String.valueOf(params.get("idtion"));
		if (StringUtils.isNotBlank(idtion)) {
			sql.append(" and idtion like'%'||'" + idtion + "'||'%'");
		}

		String vmoney = params.get("vmoney") == null ? null : String.valueOf(params.get("vmoney"));
		if (StringUtils.isNotBlank(vmoney)) {
			sql.append(" and vmoney like'%'||'" + vmoney + "'||'%'");
		}
		// String staffint = params.get("staffint") == null ? null :
		// String.valueOf(params.get("staffint"));
		// if (StringUtils.isNotBlank(staffint)) {
		// sql.append(" and staffint like'%'||'" + staffint + "'||'%'");
		// }

		// String name = params.get("name") == null ? null :
		// String.valueOf(params.get("name"));
		// if (StringUtils.isNotBlank(name)) {
		// sql.append(" and name like'%'||'" + name + "'||'%'");
		// }

		// String idNumber = params.get("idNumber") == null ? null :
		// String.valueOf(params.get("idNumber"));
		// if (StringUtils.isNotBlank(idNumber)) {
		// sql.append(" and idNumber like'%'||'" + idNumber + "'||'%'");
		// }
		return bo.getExpResult(sql.toString(), page);
	}

	/**
	 * 保存最低工资参数
	 * 
	 * @param data
	 * @return
	 */
	public Integer saveMiniwase(Miniwase data) {
		return bo.saveMiniwase(data);
	}

	/**
	 * 删除最低工资参数
	 * 
	 * @param ids
	 * @return
	 */
	public Integer delMiniwase(Integer[] ids) {
		return bo.delMiniwase(ids);
	}

	/**
	 * 查询最低工资参数
	 * 
	 * @param params
	 * @return
	 */
	public Result queryMiniwase(Map<String, Object> params) {
		Page page = (Page) params.get("page");
		StringBuffer buff = new StringBuffer("from Miniwase where 1=1 and isDelete='" + SalConstant.NOT_DELETE + "' ");

		String did = params.get("did") == null ? null : String.valueOf(params.get("did"));
		if (StringUtils.isNotBlank(did)) {
			buff.append(" and did='").append(did + "'");
		}

		String engli = params.get("engli") == null ? null : String.valueOf(params.get("engli"));
		if (StringUtils.isNotBlank(engli)) {
			buff.append(" and engli like'%'||'" + engli + "'||'%'");
		}

		String engtype = params.get("engtype") == null ? null : String.valueOf(params.get("engtype"));
		if (StringUtils.isNotBlank(engtype)) {
			buff.append(" and engtype like'%'||'" + engtype + "'||'%'");
		}

		String idtion = params.get("idtion") == null ? null : String.valueOf(params.get("idtion"));
		if (StringUtils.isNotBlank(idtion)) {
			buff.append(" and idtion like'%'||'" + idtion + "'||'%'");
		}

		String vmoney = params.get("vmoney") == null ? null : String.valueOf(params.get("vmoney"));
		if (StringUtils.isNotBlank(vmoney)) {
			buff.append(" and vmoney like'%'||'" + vmoney + "'||'%'");
		}
		return bo.queryMiniwase(buff.toString(), page);
	}

}
